﻿--职级异动一级审批
CREATE proc [dbo].[proc_Employee_GradeMove_Audit]
(
	@Id int,
	@Audit bit,
	@Memo text,
	@UserName nvarchar (50),
	@AuditTime nvarchar(50)

)
as
	begin
	
	declare @FirstAuditPerson nvarchar(50)
	set @FirstAuditPerson = (select FirstAuditPerson from employee_Grade where id=@id)
	declare @eid int
	set @eid = (select eid from employee_Grade where id=@id)
	declare @GradeId int
	set @GradeId = (select AGradeId from employee_Grade where id=@id)
		--一级审批
		if(@FirstAuditPerson is null)
			begin
				update employee_Grade set FirstAudit=@Audit,FirstMemo=@Memo,FirstAuditPerson=@UserName,FirstAuditTime=@AuditTime where id=@id
			end
		--二级审批
		else
			begin
				update employee_Grade set SecondAudit=@Audit,SecondMemo=@Memo,SecondAuditPerson=@UserName,SecondAuditTime=@AuditTime where id=@id
				update employee set GradeId=@GradeId where id=@eid
			end
		
	end